/**
 * Created by dale on 2017/7/25.
 */
$(document).ready(function () {
    var form=$('#form');

    var $depId=addressUri.getParam('iDepId');
    $('[name="iDepId"]').val($depId);

    $('#bt_modal_confirm',parent.document).click(function () {
        // $.ajax({
        //     url:moduleUrl+'staff/importStaff',
        //     data:$('#form').serialize(),
        //     type:'POST',
        //     success:function (data) {
        //         window.top.xhTop.getActiveFrame().staffList.dataGridReload();
        //         window.top.xhTop.closeModal();
        //     },
        //     error:function (data) {
        //         console.log(data);
        //     }
        // });
        $('#bt_modal_confirm',parent.document).addClass('disabled');
        xhExtra.setBtnLoading($('#bt_modal_confirm',parent.document));
        $('#form').ajaxSubmit({
            type: 'POST',
            url: moduleUrl+'staff/importStaff',
            dataType: 'json',
            success:function (responseText, statusText, xhr, $form) {
                if(statusText=='success'){
                    window.top.swal('插入成功',responseText['message'],'success')
                }
                window.top.xhTop.getActiveFrame().staffList.dataGridReload();
                window.top.xhTop.closeModal();
            },
            error : function(xhr, status, err) {
                console.log(err);
                console.log(xhr);
                alert("操作失败");
            }
        });
        
        
        //form.submit();
        // window.top.xhTop.getActiveFrame().staffList.dataGridReload();
        // window.top.xhTop.closeModal();
    });
    modalBind.bindClick();
});